﻿<%@ Page Language="C#" %>

<%@ Import Namespace="Teradata.Client.Provider" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        using (TdConnection cn = new TdConnection(ConfigurationManager.ConnectionStrings["TDConnString"].ConnectionString))
        {
            try
            {
                String SQL = "SELECT TOP 1 ASOF_DATE FROM SUNRISE_TEST.ACC_BASE_DATA";
                cn.Open();
                using (TdCommand cm = new TdCommand(SQL, cn))
                {
                    cm.CommandTimeout = 0;
                    using (TdDataReader dr = cm.ExecuteReader())
                        while (dr.Read())
                        {
                            string s = String.Format("{0:MMMM} {0:yyyy} Property List", dr.GetDateTime(0));
                            Session["Connected"] = true;
                        }
                }
                TextBox1.Text = "Connected";
            }
            catch (Exception ex)
            {
                TextBox1.Text = ex.ToString();
            }

        }


    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        using (TdConnection cn = new TdConnection(ConfigurationManager.ConnectionStrings["EDW_GROUP_ID"].ConnectionString))
        {
            try
            {
                String SQL = "SELECT TOP 1 ASOF_DATE FROM MIS.ACC_BASE_DATA";
                cn.Open();
                using (TdCommand cm = new TdCommand(SQL, cn))
                {
                    cm.CommandTimeout = 0;
                    using (TdDataReader dr = cm.ExecuteReader())
                        while (dr.Read())
                        {
                            string s = String.Format("{0:MMMM} {0:yyyy} Property List", dr.GetDateTime(0));
                            Session["Connected"] = true;
                        }
                }
                TextBox2.Text = "Connected";
            }
            catch (Exception ex)
            {
                TextBox2.Text = ex.ToString();
            }

        }
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        using (TdConnection cn = new TdConnection(ConfigurationManager.ConnectionStrings["EDW_GROUP_ID"].ConnectionString))
        {
            try
            {
                string sSQLServerCn = ConfigurationManager.ConnectionStrings["ACC_NEW"].ConnectionString;
                SqlConnection cnSQLServer = new SqlConnection(sSQLServerCn);

                DataTable dtSQLServer = new DataTable();

                using (cnSQLServer)
                {
                    cnSQLServer.Open();
                    using (SqlDataAdapter da = new SqlDataAdapter("SELECT COUNT(*) FROM SCORE_ACC_PROPERTIES.PROPERTIES", cnSQLServer))
                    {
                        da.SelectCommand.CommandTimeout = 0;
                        da.Fill(dtSQLServer);
                    }
                }
                TextBox3.Text = "Connected";
            }
            catch (Exception ex)
            {
                TextBox3.Text = ex.ToString();
            }

        }
    }
    
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div>
            <asp:Button ID="Button1" runat="server" Text="Connect to RDW" OnClick="Button1_Click" />
            <br />
            <asp:TextBox ID="TextBox1" runat="server" Height="176px" TextMode="MultiLine" Width="760px"></asp:TextBox>
            <br />
            <br />
            <br />
            <asp:Button ID="Button2" runat="server" Text="Connect to EDW" Width="146px" OnClick="Button2_Click" />
            <br />
            <asp:TextBox ID="TextBox2" runat="server" Height="183px" TextMode="MultiLine" Width="760px"></asp:TextBox>
            <br />
            <br />
            <br />
            <asp:Button ID="Button3" runat="server" Text="Connect to SQL Server" Width="146px"
                OnClick="Button3_Click" />
            <br />
            <asp:TextBox ID="TextBox3" runat="server" Height="183px" TextMode="MultiLine" Width="760px"></asp:TextBox>
        </div>
    </div>
    </form>
</body>
</html>
